package collection;

import java.util.Arrays;
import java.util.List;

public class ArrayToList {
    public static void main(String[] args) {
        String[] array = {"one", "two", "three", "four", "five"};
        System.out.println(Arrays.toString(array));

        List<String> list = Arrays.asList(array);
        System.out.println(list);

        array[3] = "eight";//对数组进行操作
        System.out.println(Arrays.toString(array));
        System.out.println();

        list.set(4,"nine");//对集合进行操作
        System.out.println(Arrays.toString(array));
        System.out.println(list);



       /*
       给集合添加/删除元素相当于给数组添加/删除元素
       而数组是定长的,不会自动扩容/缩容,因此发生不支持操作异常
        */
       // list.add("!!!!!");//UnsupportedOperationException不支持操作异常




       /* List<String> list = Arrays.asList(array);
        System.out.println(list);

        array[1] = "six";
        System.out.println(Arrays.toString(array));
        System.out.println(list);

        list.set(2, "seven");
        System.out.println(Arrays.toString(array));
        System.out.println(list);*/

    }
}
